using System;
using MetaObjects.Contracts;

namespace MetaObjects.Core
{
	public abstract class MetaEntityProvider<TMetaEntity> : IMetaEntityProvider<TMetaEntity>
	{
		public Func<TMetaEntity, IMetaEntity> EntityFactory { get; set; }
		Func<object, IMetaEntity> IMetaEntityProvider.EntityFactory
		{
			get { return e => EntityFactory((TMetaEntity)e); }
		}
        
		public MetaEntityProvider()
		{
			EntityFactory = GetMetaEntity;
		}

		protected abstract IMetaEntity GetMetaEntity(TMetaEntity entity);
	}
}